package com.hongyan.dao;

import com.hongyan.bean.Admin;
import com.hongyan.bean.Student;
import com.hongyan.bean.Teacher;
import com.hongyan.util.JDBCUtils;

public class UserDao {



    public static Admin findAdminById(String username) {
        Admin admin = JDBCUtils.queryByconditionOne("select * from a_info where a_id = ?", Admin.class, username);
        return admin;
    }
    public static Student findStudentById(String username) {
        Student student = JDBCUtils.queryByconditionOne("select * from s_info where s_id = ?", Student.class, username);
        return student;
    }

    public static int updateStudent(Student student) {
        return JDBCUtils.update("update s_info set s_name = ?, sex = ?, contact = ?, college = ?  where s_id = ?", student.getS_name(), student.getSex(), student.getContact(), student.getCollege(), student.getS_id());
    }
    public static Teacher findTeacherById(String username) {
        Teacher teacher = JDBCUtils.queryByconditionOne("select * from t_info where t_id = ?", Teacher.class, username);
        return teacher;
    }
    public static int updateTeacher(Teacher teacher) {
        return JDBCUtils.update("update t_info set t_name = ?, sex = ?, contact = ?, college = ?  where t_id = ?", teacher.getT_name(), teacher.getSex(), teacher.getContact(), teacher.getCollege(), teacher.getT_id());
    }


    public static int updateAdmin(Admin admin) {
        return JDBCUtils.update("update a_info set a_name = ?, sex = ?, contact = ?   where a_id = ?", admin.getA_name(), admin.getSex(), admin.getContact(), admin.getA_id());

    }
}
